#ifndef __BSP_FLASHDB_H
#define __BSP_FLASHDB_H
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "default_param.h"
#define REVERSE_BYTE(x,len) do{\
char *ptr=(char*)x;\
for(int i=0;i<len;i++)\
{\
	*ptr&=~(*ptr);\
	ptr++;\
}\
}while(0)\



typedef struct
{
	char *name;
	uint32_t Start_Addr;
	uint32_t DataLen;
	
}PART_TABLE;



#ifdef CHIP_TYPE_F4
#define FLASH_TABLE_F4 	{\
	{"program",	0x08000000,0x08040000-0x08000000-1},\
	{"logo",	0x08040000,0x08060000-0x08040000-1},\
	{"param",	0x08060000,0x08080000-0x08060000-1},\
}
#endif

#ifdef CHIP_TYPE_L4
#define FLASH_TABLE_L4 	{\
	{"program",	0x08000000,0x08080000-0x08000000-1},\
	{"logo",	0x08080000,0x08081000-0x08080000-1},\
	{"param",	0x08081000,0x08082000-0x08081000-1},\
};
#endif
#ifdef CHIP_TYPE_L1
#define FLASH_TABLE_L1 	{\
	{"program",	0x08000000,0x08080000-0x08000000-1},\
	{"logo",	0x08080000,0x08081000-0x08080000-1},\
	{"param",	0x08080000, 0x08080fff-0x08080000},\
};
#endif

	
int 		FlashParam_Read(uint32_t ReadOffestAddr,char* buf,int len);
int 		FlashParam_Write(uint32_t WriteOffestAddr,char* buf,int len);
int 		FlashParam_Check(Flash_Param *fp);

int 		FlashParam_Modify(Flash_Param *param);
int 		FlashParam_Reset(void);

int 		Flash_Find(char *name);
void 		FlashParam_Print(void);
Flash_Param *FlashGetParam(void);
int 		Dev_Data_Write(uint32_t DevStartAddr,int Dev_Len,uint32_t WriteOffestAddr,char* buf,int len);
int 		Dev_Data_Read(uint32_t DevStartAddr,int Dev_Len,uint32_t ReadOffestAddr,char* buf,int len);
#endif








